# -*- coding: utf-8 -*-

import os # 引入os

# 引入Qt内容
from PyQt5.QtWidgets import ( 
    QMainWindow, 
    QToolBar, 
    QAction, 
    QDockWidget, 
    QTextEdit, 
    QStatusBar,
    QWidget,
    QVBoxLayout
)

from PyQt5.QtCore import (
    Qt
)

class MainWindow(QMainWindow):
    def __init__(self,title):
        super().__init__()
        
        # 设置窗口标题
        self.setWindowTitle(title)

        # 创建一个工具栏
        self.toolbar = QToolBar("工具栏")
        self.addToolBar(self.toolbar)

        # 添加一个动作到工具栏
        self.action = QAction("测试按钮", self)
        self.toolbar.addAction(self.action)

        # 创建中央部件
        self.central_widget = QWidget()
        self.layout = QVBoxLayout()
        self.central_widget.setLayout(self.layout)
        self.setCentralWidget(self.central_widget)

        # 创建状态栏
        self.statusbar = QStatusBar()
        self.setStatusBar(self.statusbar)
        self.statusbar.showMessage("准备就绪")

        # 设置主窗口的大小
        self.resize(1000, 600)

    def addWidget(self,widget:QWidget):
        self.layout.addWidget(widget)


    def addAction(self,action:QAction):
        self.toolbar.addAction(action)

    def addDockWidget(self,dock_widget:QDockWidget):
        dock_widget.setMaximumWidth(300)
        super().addDockWidget(Qt.LeftDockWidgetArea, dock_widget)